import { reqGetGoodsList } from "../../api/search";

const state = {
	goodsList: [],
	trademarkList: [],
	attrsList: [],
	total: 0
};

const getters = {};

const actions = {
	async getGoodsList(store, options) {
		try {
			const response = await reqGetGoodsList(options);
			store.commit("GET_GOODS_LIST", response);
		} catch (error) {
			console.log(error);
		}
	}
};

const mutations = {
	GET_GOODS_LIST(state, data) {
		state.goodsList = data.goodsList;
		state.trademarkList = data.trademarkList;
		state.attrsList = data.attrsList;
		state.total = data.total;
	}
};

export default {
	namespaced: true,
	state,
	getters,
	actions,
	mutations
};
